package com.joesem.sale.client.logic.mine

import android.app.Application
import com.joesem.sale.client.base.BaseViewModel
import com.joesem.sale.client.base.request
import com.joesem.sale.client.base.toast
import com.joesem.sale.client.network.data.AccountMode


class MineViewModel(application: Application) : BaseViewModel(application) {

    fun getUserAccount() {
        request(false, request = {
            account()
        }, response = { it ->
            it.data?.let {
                actionIntent(AccountIntent(it))
            } ?: run {
                toast(it.msg)
                actionIntent(AccountIntent(null))
            }
        }, responseFailed = {
            toast(it.message)
            actionIntent(AccountIntent(null))
        })
    }

    class AccountIntent(val data: AccountMode?)
}